package com.zhentao.equipment.controller;

import com.zhentao.equipment.service.DeviceConfigService;
import com.zhentao.util.ResultVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * 设备配置接口
 */
@RestController
@RequestMapping("/api/devices")
@CrossOrigin(origins = "*")
public class DeviceConfigController {

    @Autowired
    private DeviceConfigService service;

    /** 获取某设备的所有配置 */
    @GetMapping("/{id}/configs")
    public ResultVo getAll(@PathVariable("id") Long deviceId) {
        return service.getAll(deviceId);
    }

    /** 批量设置配置（覆盖） */
    @PutMapping("/{id}/configs")
    public ResultVo setAll(@PathVariable("id") Long deviceId, @RequestBody Map<String, String> configs) {
        return service.setAll(deviceId, configs);
    }
}





